
package flc.ast.adapter;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyFormatBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class FormatAdapter extends StkProviderMultiAdapter<MyFormatBean> {

    public FormatAdapter() {
        addItemProvider(new StkSingleSpanProvider(30));
        addItemProvider(new FormatProvider());
    }

    private class FormatProvider extends BaseItemProvider<MyFormatBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_format;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyFormatBean bean) {
            baseViewHolder.setText(R.id.tvFormatItemName, bean.getName());
            if (bean.isSelected()) {
                baseViewHolder.setImageResource(R.id.ivFormatItemSel, R.drawable.xuanzhong2);
            } else {
                baseViewHolder.setImageResource(R.id.ivFormatItemSel, R.drawable.weixuanzhong2);
            }
        }
    }
}
